//index.js
//获取应用实例
const app = getApp()
const mineService = require('../../service/mine.js');

Page({
  data: {
    title:"达人任务",
    list: [],
    queryParams: {
      page: 1,
      num: 10
    },
    isLast: false,
    dictionary:{
      typeList:{
        0:"动态邀约",
        1:"视频邀约",
        2:"文章邀约",
        3:"问答邀约"
      }
    }
  },
  onLoad: function () {
    
  },
  onShow: function () {
    if (app.checkLogin()) {
      this.data.list = "";
      this.getContentList();
    };
  },
  getContentList() {
    let d = {
      ...this.data.queryParams,
      unionId: app.globalData.userinfo.unionId
    }
    mineService.getMineInvite(d).then(res => {
      if (res.resCode == 0) {
        if (!res.object.length) {
          this.setData({
            isLast: true
          });
          return false;
        }
        this.setData({
          list: [
            ...this.data.list,
            ...res.object
          ]
        });
      }
    })
  },
  onReachBottom() {
    if (this.data.isLast) return false;
    this.setData({
      queryParams: {
        page: ++this.data.queryParams.page,
        num: 10
      }
    })
    this.getContentList();
  },
  onShareAppMessage(options) {
    return {
      imageUrl: "https://pic.ditieshequ.com/pic/daren-background-image.jpg",
      title: "地铁社区达人招募开始啦！参加达人任务，享受内容变现！更多福利等你来战！"
    }
  }
})
